import { action, computed, observable, useStrict } from 'mobx'
import { Actions } from './actions'

useStrict(true)

export class Store {
  @observable authentication = { token: undefined, userId: undefined }

  @observable user = {}

  @observable cart = []

  @computed
  get profile() {
    return this.user
  }

  hasRole(role) {
    return this.user.role === role.toUpperCase()
  }

  actions = new Actions(this)
}

export default new Store()
